//
//  PersonalInfomationViewController.m
//  BigToBig
//
//  Created by 毛丽媛 on 16/8/31.
//  Copyright © 2016年 cn.cloudtp. All rights reserved.
//

#import "PersonalInfomationViewController.h"

@interface PersonalInfomationViewController ()

@end

@implementation PersonalInfomationViewController

@synthesize btnSelect;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    UILabel *titleLab = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 40)];
    titleLab.text = self.titleName;
    titleLab.textColor = [UIColor whiteColor];
    [self setBackBar];
    titleLab.textAlignment = NSTextAlignmentCenter;
    self.navigationItem.titleView = titleLab;
    
    self.navigationController.navigationBar.translucent = NO;
    
    
    UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(30, 20, 100, 25)];
    lab.text = @"请选择职位";
    lab.textColor = [UIColor lightGrayColor];
    [self.view addSubview:lab];
    
    
    btnSelect = [[UIButton alloc] initWithFrame:CGRectMake(20, 50, kScreenWidth - 40, 40)];
    btnSelect.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:btnSelect];
    
    
    btnSelect.layer.borderWidth = 1;
    btnSelect.layer.borderColor = [[UIColor lightGrayColor] CGColor];
    btnSelect.layer.cornerRadius = 5;
    
    [btnSelect addTarget:self action:@selector(chooseClick:) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)chooseClick:(UIButton *)btn{
    NSArray * arr = [[NSArray alloc] init];
    arr = [NSArray arrayWithObjects:@"创始人", @"市场负责人", @"技术负责人", @"运营负责人", @"产品负责人",nil];
    if(dropDown == nil) {
        CGFloat f = arr.count * 40;
        dropDown = [[NIDropDown alloc]showDropDown:btn :&f :arr :@"down"];
        dropDown.delegate = self;
    }
    else {
        [dropDown hideDropDown:btn];
        [self rel];
    }
}

- (void)viewDidUnload {
    btnSelect = nil;
    [self setBtnSelect:nil];
    [super viewDidUnload];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)niDropDownDelegateMethod: (NIDropDown *) sender {
    [self rel];
}

-(void)rel{
    dropDown = nil;
}

- (void)setBackBar{
    
    BackButton *backBtn=[BackButton buttonWithType:UIButtonTypeCustom];
    backBtn.frame = CGRectMake(0, 0, 20, 44);
    [backBtn addTarget:self action:@selector(backController) forControlEvents:UIControlEventTouchUpInside];
    [backBtn setImage:[UIImage imageNamed:@"返回"] forState:UIControlStateNormal];
    [backBtn.imageView setContentMode:UIViewContentModeLeft];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backBtn];
    [self.navigationItem setHidesBackButton:YES animated:YES];
    
    BackButton *saveBtn=[BackButton buttonWithType:UIButtonTypeCustom];
    saveBtn.frame = CGRectMake(kScreenWidth - 44,0 , 44, 44);
    [saveBtn addTarget:self action:@selector(SaveMessage) forControlEvents:UIControlEventTouchUpInside];
    [saveBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [saveBtn setTitle:@"保存" forState:UIControlStateNormal];
    [saveBtn.imageView setContentMode:UIViewContentModeLeft];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:saveBtn];
    [self.navigationItem setHidesBackButton:YES animated:YES];
    
}

- (void)SaveMessage{
    
}

- (void)backController{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
